package ZuoYe02;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/*
String str = “fje你kw我FDQFj你feAF他Eajf他eo2FA我FEjfew”;
	请编程统计每个字符出现的次数
 */
public class Demo01 {
    public static void main(String[] args) {
        String s = "fje你kw我FDQFj你feAF他Eajf他eo2FA我FEjfew";
        Map<Character,Integer> map = new HashMap<>();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (map.containsKey(c)){
                Integer v = map.get(c);
                v++;
                map.put(c,v);
            }else {
                map.put(c,1);
            }
        }
        Set<Character> keys = map.keySet();
        for (Character key : keys) {
            System.out.println("字符:"+key+"共出现:"+map.get(key));
        }
    }
}
